<?php
namespace app\common\taglib;
use think\template\TagLib;

/**
*自定义标签库 
*/
class UntilTag extends TagLib
{
	protected $tags = [
		'orderstatus' => ['attr'=> 'id,name,class' ,'close' => 0],
	];

	/**
	 * 订单状态
	 * !empty($tag['class'])订单列表页状态选择
	 * [tagOrderstatus description]
	 * @param  [type] $tag     [description]
	 * @param  [type] $content [description]
	 * @return [type]          [description]
	 */
	public function tagOrderstatus($tag,$content){
		$name = !empty($tag['name']) ? $tag['name'] : '7';
		$order_id = !empty($tag['id']) ? $tag['id'] : '0';
		$class = !empty($tag['class']) ? $tag['class'] : 'order-edit-status';
		$name = $this->autoBuildVar($name); //转化为变量形式
		$order_id = $this->autoBuildVar($order_id);
		$parseStr = '<?php $order_type = config("website.order_type");$status_selected = " "; $order_id = '.$order_id.';';
		$parseStr .= '$order_status_list = "<select class=\''.$class.' form-control\' name=\'status\' style=\'width:auto;\'>";';
		$parseStr .= !empty($tag['class']) ? '$order_status_list .= "<option value=\'all\' selected>全部</option>";' : ' $status = $order_type['.$name.']; ';//两种情况判断
		$parseStr .= 'foreach($order_type as $key=>$value){
						if(isset($status))
							$status_selected = ('.$name.' == $key) ?  "selected" : " ";	
						
						$order_status_list .= "<option data-id=\'".$order_id."\' value=\'".$key."\'".$status_selected.">".$value."</option>";
						}
						$order_status_list .= "</select>";					
						';
		$parseStr .= 'echo $order_status_list;';
		$parseStr .= '?>';
		return $parseStr;
	}

}